<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17-4-19
 * Time: 下午2:47
 */

namespace Home\Controller;

use Think\Controller;

class BaseController extends Controller{
    public function __construct(){
        parent::__construct();
        $refurl = urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
        $refurl = str_replace('&','|',$refurl);
        
        $wxaccount = M('wxaccount')->where(array('wx_id'=>1))->find();
        $return_url = BASE_SITE_URL."/Home/Oauth/getcode";
        $return_url = urlencode($return_url);
        $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$wxaccount['wx_appid'];
        $url.="&redirect_uri=".$return_url."&response_type=code&scope=snsapi_userinfo&state=0#wechat_redirect";

        header("Location:{$url}");
        exit;        
    }    
} 